<?php
class AttachmentModel extends BaseModel {
	/**
	 * <h2>日志对象</h2>
	 *
	 * @var Logger
	 */
	private $_logger;
	public function __construct() {
		parent::__construct ();
		Logger::configure ( ROOT_PATH . 'config/log_config.xml' );
		$this->_logger = Logger::getLogger ( __CLASS__ );
	}
	
	/**
	 * <h2>获取指定ID的附件的详细信息</h2>
	 *
	 * @param int $aid
	 *        	Attachment id
	 * @return CMAP Attachemnt profile
	 */
	public function getDetail($aid) {
		$query = 'select id, ts_upload, mime, uniqname, filename, comment from attachments where id=:id LIMIT 1';
		// @formatter:off
		$param = array('id'=>$aid);
		$map[] = array('id','int');
		// @formatter:on
		$resultSet = $this->_conn->select ( $query, $param, $map );
		if (count ( $resultSet )) {
			return new CMAP ( $resultSet [0] );
		} else {
			return new CMAP ();
		}
	}
}